package com.ymttest.database.mapping;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ymttest.database.model.PPBussinessOrder;
import com.ymttest.database.model.PPPayment;
import com.ymttest.database.model.RefundRequest;

public interface PaymentMapper {
	List<PPPayment> selectPPPaymentByBussinessOrderId(Map m);

	List<PPBussinessOrder> selectPPBussinessorderByTraceId(Map m);
	
	List<PPBussinessOrder> selectPPBussinessorderByOrderId(Map m);
	/**
	 * 查询7天之前的没有对账过（CheckStatus） PayPrice 和 trading amount 一致 的数据的 PaymentId
	 * 
	 * @param m
	 *            {paytype=？,paystats=?}
	 * @return PaymentId
	 */
	String selectNoCheckPPaymentId(Map m);
	
	/**
	 * 查询退款信息 
	 * @param m {pid=PaymentId}
	 * @return
	 */
	List<RefundRequest> selectRefundRequestByPaymentId(Map m);
//	List<RefundRequest> selectRefundRequestByPId(Map m);
	/**
	 * 查询退款信息 
	 * @param m {tid=traceid}
	 * @return
	 */
	Map selectRefundRequestByTraceId(Map m);
	/**
	 * 查询发货信息 
	 * @param m {pid=PaymentId}
	 * @return
	 */
	Map selectCompensateProcessInfoByPaymentId(Map m);
	/**
	 * 查询退款信息 
	 * @param m {rno=RefundBatchNo}
	 * @return
	 */
	Map selectRefundRequestByRefundBatchNo(Map m);
	
	/**查询accounting信息
	 * @param m {bid=RefundBatchNo}
	 * @return
	 */
	Map selectPPAccoutingLogByBizno(Map m);
	/**
	 * 查询mock记录
	 * @param m {mockid=mockid}
	 * @return
	 */
	Map selectMockHttpRecordByMockId(Map m);
	/**
	 * 更新退款状态
	 * m.put("refundno", refundno);
        m.put("status", status);
	 * @param m
	 * @return
	 */
	int updateRefundStatus(Map m);
	
	/**
	 * 更新退款审核是否通过
	 * @param m
	 * @return
	 */
	int updateRefundSoftDeleteFlag(Map m);
	//修改审核状态 0 未审核 1 审核 9 自动审核(快速退款)
	int updateRefundApproveStatus(Map m);
	Map selectRefundRequestByRefundId(Map m);
	
	/**
	 * 更新NotifyStatus状态
	 * @param m	 
	   m.put("pid", pid);
        m.put("status", status);
	 * @return
	 */
	int updateNotifyStatus(Map m);
	int updatePayStatus(Map m);
	Map selectCmbAggrementByUId(Map m);
	int deleteCmbAggrementByUId(Map m);
	/**
	 * 更新RefundRequest 的RefundNo
	 * @param m
	 * @return
	 */
	int updateRefundNo(Map m);
	
	@Select("select * from PP_Payment where BussinessOrderId in(select BussinessOrderId from PP_BussinessOrder where orderid=#{tradid})")
	List<PPPayment> selectPPPaymentByTradingId(@Param("tradid")String tradid);
	
}